package com.sjh.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sjh.service.IOrder_service;
import com.sjh.vo.Bis_bisiness_order;
import com.xbw.bean.Bis_Shop;
import com.zsy.bean.Bis_Shop_User;

@Controller
public class Order_controller {
		@Autowired
		 private IOrder_service order_service;
		
		@RequestMapping("selorder")
		public String selorder(Map<String, Object> map,Bis_bisiness_order order){
			List<Map> listsel = order_service.selorder(order);
		/*	System.out.println("444444444444"+order);
			System.out.println("111111"+listsel);*/
			map.put("listsel", listsel);
			
			List<Bis_Shop> listshop = order_service.selshop();
			map.put("listshop", listshop);
			
			return "sjh/selectOrder";
		}
		       
		
		
		//前台显示所有
		@RequestMapping("Qtbisiness")
		public String Qtbisiness(Map<String, Object> map,Bis_bisiness_order order,HttpSession sess){
			
			
			Bis_Shop_User shopuser=(Bis_Shop_User) sess.getAttribute("shopuser");
		/*	System.out.println(shopuser.getShop_id()+"-----------------------------------");*/
			
			Map<String, Object> map2=new HashMap<String,Object>();
			map2.put("shop_id",shopuser.getShop_id() );
			List<Map> qtlist = order_service.Qtbisiness(map2);
			map.put("list", qtlist);
			
			List<Bis_Shop> listop = order_service.selshop();
			map.put("listop", listop);
			
			return "qtsjh/selectOrder";
		}
		
				//详情
				@RequestMapping(value="orderselectByid",produces = "text/plain;charset=utf-8")
				@ResponseBody
				public String orderselectByid(String order_id,HttpServletResponse response){
					String jsonStr = "";
					
					try {
						jsonStr = new ObjectMapper().writeValueAsString(order_service.orderselectByid(order_id));
					/*System.out.println(jsonStr+"-----------");*/
					} catch (Exception e) {
					}
					return jsonStr;
				}
}
